var ir, bangla, banglaSafe="";

var reserved = "2445,2446,2449,2450,2473,2481,2483,2484,2485,2444,2500,2501,2502,";
function drawVirtualKeyboard(){
	var counter = 0;
	for(i=2437; i<=2489;i++)
	{
		//
		ir = reserved.indexOf(i+",");

		if (ir=="-1"){
			bangla = "\\u0"+num2hex(i);
			banglaSafe = "&#"+i+";";
			if (i<2453 )
			drawButton(i,"vkvowels");
			else{
				drawButton(i,"vkconsonants");
				counter++;
			}

			//$("<input  type='button' onclick='insertAtCursor(\""+bangla+"\")' value='"+banglaSafe+"' />").appendTo('#consonants');

			if ( i>2453 && counter>=10) {
				$("<br/>").appendTo("#vkconsonants");
				counter=0;
			}
		}
	}

	drawHexButton("\u0995\u09CD\u09B7","vkconsonants");
	drawHexButton("\u09DC","vkconsonants");
	drawHexButton("\u09DD","vkconsonants");
	drawHexButton("\u09DF","vkconsonants");
	drawHexButton("\u09CE","vkconsonants");
	drawHexButton("\u0982","vkconsonants");
	drawHexButton("\u0983","vkconsonants");
	drawHexButton("\u0981","vkconsonants");

	$("#vkvowels input").attr("class","bangla2");
	$("#vkconsonants input").attr("class","bangla1");

	$("<input class='bangla1 space' type='button' onclick='insertAtCursor(\" \")' value='\u09B8\u09CD\u09AA\u09C7\u09B8' />").appendTo('#vkconsonants');
	$("<input class='bangla1 dari' type='button' onclick='insertAtCursor(\"\u0964\")' value='\u0964' />").appendTo('#vkconsonants');
	$("<input class='bangla1 space' type='button' onclick='insertAtCursor(\"\u09CD\")' value='\u09AF\u09C1\u0995\u09CD\u09A4\u0020\u0995\u09B0\u09C1\u09A8' />").appendTo('#vkconsonants');
	$("<br/>").appendTo("#vkconsonants");


	for(i=2534; i<=2543;i++)
	{
		bangla = "\\u0"+num2hex(i);
		banglaSafe = "&#"+i+";";
		$("<input  type='button' onclick='insertAtCursor(\""+bangla+"\")' value='"+banglaSafe+"' />").appendTo('#vknumbers');
	}

	for(i=2494; i<=2504;i++)
	{
		ir = reserved.indexOf(i+",");

		if (ir=="-1"){
			bangla = "\\u0"+num2hex(i);
			banglaSafe = "&#"+i+";";
			$("<input  type='button' onclick='insertAtCursor(\""+bangla+"\")' value='"+banglaSafe+"' />").appendTo('#vkkars');
		}
	}

	drawButton("2507","vkkars");
	drawButton("2508","vkkars");
	$("<input class='bangla1' type='button' onclick='insertAtCursor(\"\u09CD\u09AF\")' value='\u09CD\u09AF' />").appendTo('#vkkars');

	$("#vknumbers input").attr("class","bangla1");
	$("#vkkars input").attr("class","bangla2");
}
function num2hex(num)
{
	num = new Number(num);
	return num.toString(16);
}

function hex2num(hex)
{
	return parseInt(hex,16);
}

function drawButton(value, container, cls)
{
	//if (cls=="")
	bangla = "\\u0"+num2hex(value);
	banglaSafe = "&#"+value+";";
	$("<input type='button' onclick='insertAtCursor(\""+bangla+"\")' value='"+banglaSafe+"' />").appendTo('#'+container);
}

function drawHexButton(value, container)
{
	$("<input  type='button' onclick='insertAtCursor(\""+value+"\")' value='"+value+"' />").appendTo('#'+container);
}

function hideVk()
{

	//$("#keyb").hide("slow");
	$("#keyb").hide();
}

function showVk(top, left)
{
	$("#keyb").css({"top":top,"left":left,"zIndex":1000});
	//$("#keyb").show("slow");
	$("#keyb").show();
}